/*
 * @Author: your name
 * @Date: 2020-08-11 21:47:15
 * @LastEditTime: 2020-08-11 21:48:59
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \day01\traning\test03\main.go
 */
package main

import "fmt"

func calc(index string, a, b int) int {
	ret := a + b
	fmt.Println(index, a, b, ret)
	return ret
}

// 注意赋值语句，是在defer之前，defer实在return之前
func main() {
	x := 1
	y := 2
	defer calc("AA", x, calc("A", x, y))
	x = 10
	defer calc("BB", x, calc("B", x, y))
	y = 20
}
